import requests
from log.log import test_log





#请求参数封装
def request_run_main(url=None,header=None,data=None,method="post",content_Type="application/json"):

    #记录日志
    test_log.info('请求开始:请求url：{},请求数据：{}，请求头：{}'.format(url,data,header))
    try:
        if method=='get':
            response=requests.get(url=url,headers=header,data=data)
        elif content_Type=="application/json":
            response=requests.post(url=url,headers=header,json=data)
        else:
            response = requests.post(url=url, headers=header, data=data)
        test_log.info("响应数据{}".format(response.json()))
        return  response
    except Exception as e:
        test_log.error(e)




